home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / time / bigtime / bin / user / usertemplate.c < prev    next >
C/C++ Source or Header  |  1995-10-19  |  2KB  |  87 lines

  1. /* --------------------------------------------------------------------------- */
  2. /*    Name: UserTemplate.c
  3.  *  Author: aleph NULL (Silicon Based Life)
  4.  *    Date: 8/10/95
  5.  * Comment: (c) Copyright 1995 Silicon Based Life
  6.  *        :
  7.  */
  8. /* --------------------------------------------------------------------------- */
  9. /* #includes */
  10.  
  11. #include <exec/ports.h>
  12. #include <exec/types.h>
  13.  
  14. #include <clib/exec_protos.h>
  15.  
  16. #include "UserTemplate.h"
  17. #include "UserTemplate_protos.h"
  18.  
  19. /* --------------------------------------------------------------------------- */
  20. /* main */
  21.  
  22. main( int argc, char **argv )
  23. {
  24.  struct MsgPort     *mp   = NULL;
  25.  struct UserMessage *um   = NULL;
  26.  BOOL                Done = FALSE;
  27.  
  28.  if(!( mp = CreateMsgPort() ))
  29.      goto Exception;
  30.  
  31.  mp->mp_Node.ln_Name = DEFAULT_USER_PORT;
  32.  mp->mp_Node.ln_Pri  = 50;
  33.  
  34.  AddPort( mp );
  35.  
  36.  if(!( InitUserClock() ))
  37.      goto Exception;
  38.  
  39.  while(! Done )
  40.      {
  41.       WaitPort( mp );
  42.       while( um = (struct UserMessage *)GetMsg( mp ) )
  43.           {
  44.            switch( um->um_Event )
  45.                {
  46.                 case OPENFACE:
  47.                     OpenUserClock();
  48.                     break;
  49.                 case CLOSEFACE:
  50.                     CloseUserClock();
  51.                     break;
  52.                 case CHIME:
  53.                     ChimeUserClock();
  54.                     break;
  55.                 case ALARM:
  56.                     AlarmUserClock();
  57.                     break;
  58.                 case TIME:
  59.                     UpdateUserClock();
  60.                     break;
  61.                 case PREFS:
  62.                     OpenUserClockPrefs();
  63.                     break;
  64.                 case QUIT:
  65.                     Done = TRUE;
  66.                     break;
  67.                }
  68.            ReplyMsg( (struct Message *)um );
  69.           }
  70.      }
  71.  
  72.  Exception:
  73.      FreeUserClock();
  74.      if( mp )
  75.          {
  76.           RemPort( mp );
  77.           while( um = (struct UserMessage *)GetMsg( mp ) )
  78.               ReplyMsg( (struct Message *)um );
  79.           DeleteMsgPort( mp );
  80.          }
  81.  exit(0);
  82. }
  83.  
  84. /* --------------------------------------------------------------------------- */
  85.  
  86.  
  87.